/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *                                                                  *
 *        *************************************************         *
 *        *©2021-2027 HT Corporation All rights reserved *          *
 *        *************************************************         *
 *                                                                  *
 * FileName    : h_vdec.c                                           *
 *                                                                  *
 * Author      : linus                                              *
 *                                                                  *
 * Email       : luoyaojun@haitutech.com                            *
 *                                                                  *
 * Date        : 2022-8-8                                           *
 *                                                                  *
 * Description :                                                    *
 *                                                                  *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "h_vdec.h"
#include "ht_vdec.h"

HT_S32 ht_vdec_module_register(struct ht_vdec *pvdec)
{
    return (ht_register_modules(HT_ID_VDEC, (HT_HANDLE)pvdec));
}

HT_S32 ht_vdec_init(HT_U32 chn, HT_U32 u32SrcWidth, HT_U32 u32SrcHeight, HT_CODEC_ID codec)
{
    struct ht_vdec *pvdec = HT_MPP_HANDLE_VDEC;

    if (!pvdec->ops)
        return -1;

    if (codec >= HT_VIDEO_BUTT)
        return -2;

    if (pvdec->ops->vdec_init)
    {
        pvdec->ops->vdec_init(pvdec, chn, u32SrcWidth, u32SrcHeight, codec);
    }

    return 0;
}

HT_S32 ht_vdec_exit(HT_U32 chn)
{
    struct ht_vdec *pvdec = HT_MPP_HANDLE_VDEC;

    if (!pvdec->ops)
        return -1;

    if (pvdec->ops->vdec_exit)
    {
        pvdec->ops->vdec_exit(pvdec, chn);
    }

    return 0;
}

HT_S32 ht_vdec_sendstream(HT_U32 chn, HT_U8 *addr, HT_S32 size, HT_U64 pts)
{
    struct ht_vdec *pvdec = HT_MPP_HANDLE_VDEC;

    if (chn < 0 || !addr || size <= 0)
        return -1;

    if (!pvdec->ops)
        return -2;

    if (pvdec->ops->vdec_sendstream)
    {
        pvdec->ops->vdec_sendstream(pvdec, chn, addr, size, pts);
    }

    return 0;
}

HT_VOID ht_vdec_config_sendstream_timeout(HT_U32 timeout)
{
    struct ht_vdec *pvdec = HT_MPP_HANDLE_VDEC;

    if (pvdec->ops && pvdec->ops->vdec_config_sendstream_timeout)
    {
        pvdec->ops->vdec_config_sendstream_timeout(pvdec, timeout);
    }
}

HT_VOID ht_vdec_config_vdec_delay(HT_U32 delay)
{
    //	struct ht_vdec *pvdec = HT_MPP_HANDLE_VDEC;
}
